package com.ilancuo.datastructuresandalgorithmsinjava.ch05_link;

/**
 * Created by ilancuo on 2018/8/27.
 */
public class LinkList3 {
    private LinkD first;

    public LinkList3() {
        first = null;
    }

    public boolean isEmpty() {
        return first == null;
    }

    public void insertFirst(long dd) {
        LinkD newLink = new LinkD(dd);
        newLink.next = first;
        first = newLink;
    }

    public long deleteFirst() {
        LinkD temp = first;
        first = first.next;
        return temp.dData;
    }

    public void displayList() {
        LinkD current = first;
        while (current != null) {
            current.displayLink();
            current = current.next;
        }
        System.out.println();
    }
}
